package com.mz.ieann.aide.city.api

import androidx.lifecycle.MutableLiveData
import com.mz.ieann.aide.city.bean.*
import com.mz.ieann.dokit.sdk.base.BaseDomain
import com.mz.ieann.dokit.sdk.base.BaseHttpFactory
import com.mz.ieann.dokit.utils.SdkUtils

/**
 * <p>------------------------------------------------------
 * <p> Copyright (C) 2021 zhangmz, All rights reserved.
 * <p> If there is technical discussion, you can contact zhangmz90@foxmail.com
 * <p>------------------------------------------------------
 * <p> des
 * <p>
 *
 * @author Created by zhangmz90
 * @date on 2021 2021/11/14 13:39
 */
class DaoService : BaseHttpFactory(BaseDomain.DOMAIN_ORDER) {

    private val dao by lazy { create(Dao::class.java) }

    /**
     * 获得户型列表
     */
    fun queryList(
        param : HouseParam,
        data : MutableLiveData<BaseResult<HouseResult>>,
        error : () -> Unit = {},
        complete : () -> Unit = {}
    ) {
        val timestamp = System.currentTimeMillis()
        val value = "key$timestamp"
        param.appkey = "key"
        param.timestamp = timestamp.toString()
        param.sign = SdkUtils.md5(value)
        val call = dao.queryList(SdkUtils.entityToMapString(param))
        enqueue(call, data, error, complete)
    }

    fun  queryDetail(
        planId : String,
        body : CreateWifiParam,
        data : MutableLiveData<BaseResult<HeatMapResult>>,
        error : () -> Unit = {},
        complete : () -> Unit = {}
    ){
        val timestamp = System.currentTimeMillis()
        val value = "key$timestamp"
        val param = HouseParam()
        param.appkey = "key"
        param.timestamp = timestamp.toString()
        param.sign = SdkUtils.md5(value)
        val call = dao.queryDetail(planId, SdkUtils.entityToMapString(param), body)
        enqueue(call, data, error, complete)
    }

}